package dongchel.vrp.rachelinsertion;

import java.util.ArrayList;
import java.util.List;

import dongchel.vrp.entity.City;
import dongchel.vrp.entity.GlobalInformation;
import dongchel.vrp.entity.MultiObjectiveObject;
import dongchel.vrp.entity.Route;
import dongchel.vrp.entity.Solution;
import dongchel.vrp.general.vrpinterface.ObjectivePenaltyInterface;

public class RachelObjectiveValue implements ObjectivePenaltyInterface{

	public MultiObjectiveObject getObjectiveValue(Route route) {
		// TODO Auto-generated method stub
		//we have two objective, the first one is vehicle number and second one is tour length
		MultiObjectiveObject mo = new MultiObjectiveObject();
		List objectiveList = new ArrayList();
		double tourLength = 0;
		for(int i=0;i<route.getCityList().size()-1;i++){
			City currentCity = route.getCityList().get(i);
			City nextCity = route.getCityList().get(i+1);
			tourLength += GlobalInformation.distance[currentCity.getId()][nextCity.getId()];
		}
		objectiveList.add(tourLength);
		
		mo.setObjectiveList(objectiveList);
		
		return mo;
	}

	public MultiObjectiveObject getObjectiveValue(Solution solution) {
		// TODO Auto-generated method stub
		//we have two objective, the first one is vehicle number and second one is tour length
		MultiObjectiveObject mo = new MultiObjectiveObject();
		List objectiveList = new ArrayList();
		
		objectiveList.add(solution.getRouteList().size()+0.0);
		objectiveList.add(solution.getSolutionLength());
		objectiveList.add(solution.getSolutionDuration());
		
		//objectiveList.add(solution.getTimeViolation());
		//objectiveList.add(solution.getCapacityViolation());
		
		mo.setObjectiveList(objectiveList);
		return mo;
	}

	public MultiObjectiveObject getPaneltyValue(Route route) {
		// TODO Auto-generated method stub
				
		return null;
		
	}

	public MultiObjectiveObject getPaneltyValue(Solution solution) {
		// TODO Auto-generated method stub
		MultiObjectiveObject mo = new MultiObjectiveObject();
		List objectiveList = new ArrayList();
		
		objectiveList.add(solution.getTimeViolation());
		objectiveList.add(solution.getCapacityViolation());
		
		mo.setObjectiveList(objectiveList);
		return mo;
	}

}